package com.sjy.shopmall.dao;

import com.sjy.shopmall.pojo.Cart;
import com.sjy.shopmall.vo.CartDTO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import tk.mybatis.mapper.common.BaseMapper;

import java.util.List;

@Mapper
public interface CartMapper extends BaseMapper<Cart> {

    @Select("SELECT\n" +
            "\tg.id good_id,\n" +
            "\tg.price price,\n" +
            "\tg.`name` good_name,\n" +
            "\tg.pic pic,\n" +
            "\tc.user_id owner_id,\n" +
            "\tc.id cart_id,\n" +
            "\tc.good_count AS good_count \n" +
            "FROM\n" +
            "\tcart c\n" +
            "\tLEFT JOIN goods g ON g.id = c.good_id \n" +
            "WHERE\n" +
            "\tc.user_id = #{arg0};")
    List<CartDTO> selectCartDto(Long userId);


}
